package com.fuyao.cloud.admin.flow.dto;

import cn.hutool.core.collection.CollUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

@Data
public class CompleteTaskDTO {
    /**
     * 业务系统id 必填
     */
    @ApiModelProperty(value = "业务表单唯一标识", required = true)
    private String businessKey;
    /**
     * 启动流程变量 选填
     */
    @ApiModelProperty(value = "流程变量")
    private Map<String, Object> variables;

    public Map<String, Object> getVariables() {
        if (CollUtil.isEmpty(variables)) {
            variables = new HashMap<>();
        }
        if (CollUtil.isNotEmpty(this.handlers)) {
            variables.put("handlers", this.handlers);
        }
        return variables;
    }

    @ApiModelProperty(value = "下一环节的处理人")
    private Set<String> handlers;

    @ApiModelProperty(value = "完成意见")
    private String advice;

    @ApiModelProperty(value = "下一环节任务 id")
    private String nextNodeId;

    @ApiModelProperty(value = "任务 id")
    private String taskId;

    public Map<String, Object> transientVariables() {
        Map<String, Object> transientVariables = new HashMap<>();
        if (CollUtil.isNotEmpty(this.handlers)) {
            transientVariables.put("handlers", this.handlers);
        }
        return transientVariables;
    }
}
